<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover">
    <title>Document</title>
</head>
<body>
    <form id="registerform" action="">
        <div>
            <label for="">用户名<input type="text" name="name"></label>
        </div>
        <div>
            <label for="">密码<input type="password" name="password"></label>
        </div>
        <div>
            <button type="submit">注册</button>
        </div>
    </form>
    <script src="./jquery-3.4.1.min.js"></script>
    <script>
        console.log('123');
        const $form =$('#registerform')
        $form.on('submit',(e)=>{
            e.preventDefault()
            const name = $form.find('input[name=name]').val()
            const password = $form.find('input[name=password]').val();
            console.log('456');
            console.log(name,password);
            $.ajax({
                method:"POST",
                url:'/regis',
                contentType:'text/json;charset=UTF-8',
                data:JSON.stringify({name,password})
            }).then(()=>{
                alert('注册成功')
                location.href='/index.html'
            },()=>{
                
            })
        })
    </script>
</body>
</html>